<!--  -->
<template>
    <div>
        <button @click="toTest">按钮</button><hr>
        <input type="text" width="300" ref="inp" v-if="flag">
    </div>
</template>

<script>


export default {

    data() {
        return {
            flag: false

        }
    },
    created() {

    },
    mounted() {


    },
    methods: {
        toTest() {
            this.flag = !false
            //延迟到 dom数据加载出来
            this.$nextTick(()=>{
                this.$refs.inp.focus()
            })
          
        }

    }

}
</script>
<style scoped>
/* @import url(); 引入css类 */
</style>